home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / dlink / defs.h next >
Encoding:
C/C++ Source or Header  |  1997-09-09  |  5.3 KB  |  193 lines

  1.  
  2. /*
  3.  *  DEFS.H
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  */
  9.  
  10. #include <stdarg.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <fcntl.h>
  15. #include <sys/file.h>
  16. #include <lib/version.h>
  17.  
  18. #ifdef AMIGA
  19.  
  20. #include <exec/types.h>
  21. #include <exec/lists.h>
  22. #include <exec/memory.h>
  23. #include <clib/exec_protos.h>
  24. #include <clib/dos_protos.h>
  25. #ifndef abs
  26. #define abs
  27. #endif
  28. #include <clib/alib_protos.h>
  29.  
  30. #else
  31.  
  32. #include <suplib/lists.h>
  33. #include <suplib/memory.h>
  34. #include <suplib/string.h>
  35. #include <unistd.h>
  36.  
  37. #endif
  38.  
  39. #include "error.h"
  40.  
  41. #ifdef DEBUG
  42. #define dbprintf(pri,x) if (DDebug > pri) printf x
  43. #else
  44. #define dbprintf(pri,x)
  45. #endif
  46.  
  47. #define Prototype   extern
  48. #define Local
  49.  
  50. #undef NULL
  51. #define NULL ((void *)0L)
  52.  
  53. #define ALIGN(x)    (((x) + 7) & ~3)
  54.  
  55. #ifndef O_BINARY
  56. #define O_BINARY    0
  57. #endif
  58.  
  59. #define Assert(exp) if (!(exp)) _Assert(__FILE__, __LINE__);
  60.  
  61. #ifdef SANITY_CHECK
  62. #define SanityCheck(n)    _SanityCheck(n)
  63. #else
  64. #define SanityCheck(n)
  65. #endif
  66.  
  67. typedef unsigned char    ubyte;
  68. typedef unsigned short    uword;
  69. #ifndef linux
  70. typedef unsigned long    ulong;
  71. #endif
  72.  
  73. typedef struct List    List;
  74. typedef struct Node    Node;
  75. typedef struct MinNode    MinNode;
  76.  
  77. #define NT_BSS        1
  78. #define NT_CODE     2
  79. #define NT_DATA     3
  80.  
  81. #define NT_FTOBJ    5
  82. #define NT_FTLIB    6
  83.  
  84. #define SCAN_RELOC_SYMCK    0
  85. #define SCAN_RELOC_SYMIN    1
  86. #define SCAN_RELOC_CNT        2
  87. #define SCAN_RELOC_RUN        3
  88. #define SCAN_RELOC_JUMP     4
  89. #define SCAN_COMMON_RESOLVE 5
  90.  
  91. #define RESERVED_PCJMP_TYPE 100
  92.  
  93. #define HSIZE    1024        /*  symbol hash table. WARNING, SEE HASH.A   */
  94. #define HMASK    (HSIZE-1)
  95.  
  96. #define HF_DATABSS    0x0001    /*  BSS appended onto DATA hunk, use AddSize    */
  97. #define HF_SMALLDATA    0x0002    /*  BSS or DATA hunk associated w/ small-data    */
  98.  
  99. #define HUNKIDF_FLAG    0x10000 /*  flag far data/bss hunks not part of unfragged coag */
  100.  
  101. typedef struct DBInfo {
  102.     long    di_HunkId;
  103.     long    di_Size;        /*    longwords in hunk not including this field */
  104.     long    di_Base;        /*    base offset, 0 in object module        */
  105.     long    di_LINE;        /*    'LINE'                                     */
  106.     long    di_NameSize;    /*    longwords of name               */
  107.     long    di_Ary[2];        /*    [N] name, then debug info           */
  108. } DBInfo;
  109.  
  110. typedef struct Hunk {
  111.     Node    Node;        /*    node, in ln_Type, ln_Name. linked list by name */
  112.     uword   HunkNo;        /*    hunk in module            */
  113.     struct HunkListNode *HL;/*    base of list            */
  114.     struct HunkListNode *HX;/*    secondary relocation        */
  115.     struct Module *Module;  /*    associated module / NULL    */
  116.     ulong   HunkId;        /*    hunk-id, including upper bits */
  117.     ulong   Offset;        /*    offset in final output        */
  118.     ulong   TotalBytes;     /*    extended size includes jump tab (not rounded) */
  119.     ulong   Bytes;        /*    size of hunk data        */
  120.     ulong   ExtDefs;        /*    # of exported definitions   */
  121.     ulong   *Data;        /*    CODE, DATA            */
  122.     ulong   *JmpData;        /*    more data... for jmp table  */
  123.     ulong   *Reloc32;        /*    other object file stuff     */
  124.     ulong   *Reloc16;        /*    PC   relative            */
  125.     ulong   *Reloc16D;        /*    DATA relative            */
  126.     ulong   *Reloc8;
  127.     ulong   *Ext;
  128.     ulong   *Sym;
  129.     DBInfo  *DbInfo;        /*    debug info            */
  130.     List    SymList;        /*    linked list of syms (only if SymOpt)    */
  131.     ulong   SeekDebug;        /*    seek in output file of debug hunk   */
  132.     uword   Flags;        /*    special flags            */
  133. } Hunk;
  134.  
  135. typedef struct Module {
  136.     Node    Node;        /*    link node        */
  137.     uword   Reserved;
  138.     long    NumHunks;        /*    # of hunks in module    */
  139.     Hunk    **Hunks;        /*    hunk list        */
  140.     struct FileNode *FNode; /*    file node (library)    */
  141.     char    *ModBeg;        /*    raw data location    */
  142.     char    *ModEnd;
  143. } Module;
  144.  
  145. typedef struct Sym {
  146.     MinNode Node;        /*    based at hunk (only if SymOpt)    */
  147.     struct Sym *HNext;        /*    hash link            */
  148.     Hunk    *Hunk;        /*    hunk defined in / can be NULL if type 2 */
  149.     long    Value;        /*    value of defined symbol     */
  150.     long    Refs;        /*    references            */
  151.     char    *SymName;        /*    name of symbol            */
  152.     short   SymLen;        /*    length of symbol        */
  153.     ubyte   Type;
  154.     ubyte   Flags;
  155. } Sym;
  156.  
  157. #define SYMF_SYMLIST    0x01
  158.  
  159. typedef struct FileNode {
  160.     Node    Node;
  161.     uword   Reserved;
  162.     ulong   *Data;        /*    ptr to data    */
  163.     ulong   Bytes;        /*    bytes in file    */
  164.     ulong   *DPtr;        /*    used while scanning */
  165. } FileNode;
  166.  
  167. typedef struct HunkListNode {
  168.     Node    Node;        /*    list of combined hunks    */
  169.     uword   Reserved;
  170.     ulong   HunkId;        /*    includes upper bits    */
  171.     ulong   FinalHunkNo;    /*    final assigned hunk    */
  172.     ulong   FinalSize;        /*    almost final size of hunk    */
  173.     ulong   AddSize;        /*    additional size BSS -r opt adj    */
  174.     ulong   FinalExtDefs;   /*    total # of exported definitions */
  175.     ulong   SeekSym;        /*    seek in output file of symbol hunk  */
  176.     List    HunkList;        /*    list of modules w/ same type [& name]    */
  177.     ulong   **ExtReloc32;   /*    final relocation info for hunk    */
  178.     ulong   *CntReloc32;    /*    # of relocations for each hunk    */
  179.     ulong   *CpyReloc32;    /*    moving index during final copy    */
  180. } HunkListNode;
  181.  
  182. #include "protos.h"
  183.  
  184. #ifdef AMIGA
  185.  
  186. extern void *GetHead(struct List *);
  187. extern void *GetSucc(struct Node *);
  188. extern void *GetTail(struct List *);
  189. extern void *GetPred(struct Node *);
  190.  
  191. #endif
  192.  
  193.